//
//  ZNClusterAnnotation.m
//  BaiduCluster
//
//  Created by LiZNing on 14-4-2.
//  Copyright (c) 2014年 lzning. All rights reserved.
//

#import "ZNClusterAnnotation.h"

BOOL ADClusterCoordinate2DIsOffscreen(CLLocationCoordinate2D coord) {
    return (coord.latitude == kADCoordinate2DOffscreen.latitude && coord.longitude == kADCoordinate2DOffscreen.longitude);
}


@implementation ZNClusterAnnotation


@synthesize coordinate = _coordinate;
@synthesize type = _type;
@synthesize cluster = _cluster;
@synthesize shouldBeRemovedAfterAnimation = _shouldBeRemovedAfterAnimation;

- (id)init
{
    self = [super init];
    if (self)
    {
        _cluster = nil;
        self.coordinate = kADCoordinate2DOffscreen;
        _type = ADClusterAnnotationTypeUnknown;
        _shouldBeRemovedAfterAnimation = NO;
    }
    return self;
}

- (void)setCluster:(ZNMapCluster *)cluster
{
    [self willChangeValueForKey:@"title"];
    [self willChangeValueForKey:@"subtitle"];
    _cluster = cluster;
    [self didChangeValueForKey:@"subtitle"];
    [self didChangeValueForKey:@"title"];
}

- (ZNMapCluster *)cluster
{
    return _cluster;
}

- (NSString *)title
{
    return self.cluster.title;
}

- (NSString *)subtitle
{
    return self.cluster.subtitle;
}

- (void)reset
{
    self.cluster = nil;
    self.coordinate = kADCoordinate2DOffscreen;
}

- (NSArray *)originalAnnotations
{
    NSAssert(self.cluster != nil, @"This annotation should have a cluster assigned!");
    return self.cluster.originalAnnotations;
}


@end
